package com.edt.ichannel.api.service.impl;

import com.edt.ichannel.api.dao.FirstOrderCommissionDao;
import com.edt.ichannel.api.entiy.local.FirstOrderCommission;
import com.edt.ichannel.api.service.FirstOrderCommissionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;


/**
 * FirstOrderCommission服务接口实现类
 * @author 李爽
 * @date 2019-01-10
 */
@Service
public class FirstOrderCommissionServiceImpl implements FirstOrderCommissionService {

    @Resource
    private FirstOrderCommissionDao firstordercommissionDao;


    @Override
    public List<FirstOrderCommission> getAllFirstOrderCommission() {
        return firstordercommissionDao.getAllFirstOrderCommission();
    }

    /**
     * 根据规则 查询对应产品，地市，时间段内 所有合伙人首单 并给其追加佣金
     * @param productId x_product id
     * @param cityCode 地市编码
     * @param beginDate 首充开始时间
     * @param endDate 首充结束时间
     * @param commissionMoney 追加佣金金额
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public void selectFirstCommissionAndSaveSuperadd(String productId, String cityCode, Date beginDate, Date endDate, Double commissionMoney, String type) {
        firstordercommissionDao.selectFirstCommissionAndSaveSuperadd(productId,cityCode,beginDate,endDate,commissionMoney,new Date(),type);
    }
}